package com.vdong.common.oauth.common.enums;

/**
 * @program: kpay-basics-srv
 * @description: 短信相关常量
 * @author: Mr.Zhang
 * @create: 2018-06-07 16:17
 **/
public class SmsConstant {

    public static final String SIGN_NAME = "微动天下";

    public enum VerifyCodeType {
        //模板
        //你的验证码是${code}，该验证码5分钟内有效，请勿泄露于他人！
        COMMON(0, "common", "SMS_151997003", "通用验证码"),
        //验证码${code}，您正在登录${product}，若非本人操作，请勿泄露。
        LOGIN(10, "login", "SMS_10631965", "登录验证码"),
        //验证码${code}，您正在申请入驻该店铺生产者，感谢您的支持！
        JOIN(20, "join", "SMS_136399977", "入驻申请验证码"),
        //您的验证码${code}，您正在绑定手机号，该验证码5分钟内有效，请勿泄漏于他人！
        BIND(30, "bind", "SMS_136861670", "绑定手机号"),
        //验证码${code}，您正在尝试修改${product}登录密码，请妥善保管账户信息。
        PWD(40, "pwd", "SMS_10631961", "修改密码"),
        //您的验证码${code}，您正在取消授权，该验证码5分钟内有效，请勿泄漏于他人！
        DEL_AUTH(50, "delAuth", "SMS_151577679", "取消授权"),
        ;
        private int code;
        private String type;

        /**
         * //短信模板id
         */
        private String tempCode;

        /**
         * //验证码类型
         */
        private String desc;
        /**
         * //验证码过期时间,单位分钟,默认5分钟
         */
        private Long expiredTime;

        VerifyCodeType(int code, String type, String tempCode, String desc) {
            this.code = code;
            this.type = type;
            this.tempCode = tempCode;
            this.desc = desc;
            this.expiredTime = 5L;
        }

        VerifyCodeType(int code, String type, String tempCode, String desc, Long expiredTime) {
            this.code = code;
            this.type = type;
            this.tempCode = tempCode;
            this.desc = desc;
            this.expiredTime = expiredTime;
        }

        public static VerifyCodeType findBy(String type) {
            VerifyCodeType[] value = VerifyCodeType.values();
            for (VerifyCodeType val : value) {
                if (val.type.equals(type)) {
                    return val;
                }
            }
            return null;
        }

        public int getCode() {
            return code;
        }

        public String getType() {
            return type;
        }

        public String getTempCode() {
            return tempCode;
        }

        public String getDesc() {
            return desc;
        }

        public Long getExpiredTime() {
            return expiredTime;
        }
    }

    /**
     * 通用短信
     */
    public enum SendGeneralSmsType {
        //讲师绑定手机号
        LECTUREBIND(10, "lerture_bind", "SMS_148867217", "讲师绑定手机号"),
        RESETPASSWORD(20, "rest_password", "SMS_149980619", "重置密码"),
        ;
        private int code;
        private String type;
        /**
         *  //短信模板id
         */
        private String tempCode;
        /**
         *  //说明
         */
        private String desc;

        SendGeneralSmsType(int code, String type, String tempCode, String desc) {
            this.code = code;
            this.type = type;
            this.tempCode = tempCode;
            this.desc = desc;
        }

        public static SendGeneralSmsType findBy(String type) {
            SendGeneralSmsType[] value = SendGeneralSmsType.values();
            for (SendGeneralSmsType val : value) {
                if (val.type.equals(type)) {
                    return val;
                }
            }
            return null;
        }

        public int getCode() {
            return code;
        }

        public String getType() {
            return type;
        }

        public String getTempCode() {
            return tempCode;
        }

        public String getDesc() {
            return desc;
        }
    }
}
